package com.apes.fn.server.vehicleFile.model;

import com.alibaba.fastjson.annotation.JSONField;
import com.apes.fn.server.transferVehicle.model.InnerPickDeliveryUpCar;
import com.apes.framework.jpa.DefaultPersistListener;
import com.apes.framework.jpa.Model;
import com.apes.framework.jpa.comment.Comment;
import com.apes.framework.jpa.generator.ApesGenerator;
import com.apes.framework.util.DateUtil;
import com.apes.scm.masterdata.frame.model.Dept;
import com.apes.scm.masterdata.party.model.PartyRole;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.SelectBeforeUpdate;

import javax.persistence.*;
import javax.validation.constraints.NotNull;
import java.util.Date;

/**
 * @program: apes-server
 * @description: 车辆档案账户
 * @author: czs
 * @create: 2023-11-02 11:26
 **/
@Getter
@Setter
@SelectBeforeUpdate
@DynamicInsert
@DynamicUpdate
@Entity
@EntityListeners(DefaultPersistListener.class)
@Table(name = VehicleFileAccount.CONST_TABLE_NAME)
public class VehicleFileAccount extends Model {
    public static final String CONST_TABLE_NAME = "fn_vehicle_file_account";

    @Id
    @Column(name = "id", nullable = false, length = 24)
    @ApesGenerator(code = CONST_TABLE_NAME, name = "车辆档案账户编码", padding = 6)
    private String id;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "vehicle_file_area_id", referencedColumnName = "id",nullable = false)
    @Comment("车辆档案省份")
    private VehicleFileArea vehicleFileArea;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "belong_dept_id", referencedColumnName = "id", nullable = false)
    @Comment("所属门店")
    private Dept belongDept;

    @NotNull
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "company_id", referencedColumnName = "id",nullable = false)
    @Comment("所属公司")
    private PartyRole company; //所属公司

    @Column(name = "fix_company_name", length = 32,nullable = false)
    @Comment("维修企业名称")
    private String fixCompanyName;

    @Column(name = "account", length = 32,nullable = false)
    @Comment("账号")
    private String account;

    @Column(name = "password", length = 32,nullable = false)
    @Comment("密码")
    private String password;

    @Column(name = "token", length = 512)
    @Comment("token")
    private String token;

    @JSONField(format = DateUtil.SHOW_DATETIME_FORMAT)
    @Column(name = "token_start_date")
    @Comment("token获取日期")
    private Date tokenStartDate;

    @JSONField(format = DateUtil.SHOW_DATETIME_FORMAT)
    @Column(name = "token_end_date")
    @Comment("token失效日期")
    private Date tokenEndDate;


}
